package com.shntec.xtask.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;

import com.shntec.bp.common.BaseSQLHelper;
import com.shntec.bp.common.ShntecBaseDAO;
import com.shntec.bp.util.ShntecLogger;

public class XtaskProjectsObject extends ShntecBaseDAO{
	
	private final static String THIS_TABLE_NAME = "xtask_projects";
	private final static String THIS_PRIMARY_KEY_NAME = "pid";
	
	private Integer pid = null;
	private Integer aid = null;
	private String pName = null;
	private String pDesc = null;
	private Long createTime = null;
		
	public XtaskProjectsObject(BaseSQLHelper helper){
		super(helper);
		tableName = THIS_TABLE_NAME;
		primaryKeyName = THIS_PRIMARY_KEY_NAME;
	}

	public Integer getPid() {
		return pid;
	}

	public void setPid(Integer pid) {
		this.pid = pid;
	}

	public Integer getAid() {
		return aid;
	}

	public void setAid(Integer aid) {
		this.aid = aid;
	}

	public String getpName() {
		return pName;
	}

	public void setpName(String pName) {
		this.pName = pName;
	}

	public String getpDesc() {
		return pDesc;
	}

	public void setpDesc(String pDesc) {
		this.pDesc = pDesc;
	}

	public Long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	@Override
	protected boolean loadResultSet(ResultSet rs) {
		try {
			pid = rs.getInt("pid");
			aid = rs.getInt("aid");
			pName = rs.getString("pname");
			pDesc = rs.getString("pdesc");
			createTime = rs.getLong("createtime");
		} catch (SQLException e) {
			ShntecLogger.logger.error("Handle database resultset failed, table name=" + getTableName());
			ShntecLogger.logger.error(e.getMessage());
			return false;
		}
		
		return true;
	}

	@Override
	protected HashMap<String, Object> generateColumnList() {
		HashMap<String, Object> columnList = new HashMap<String, Object>();
		
		columnList.put("pid", pid);
		columnList.put("aid", aid);
		columnList.put("pname", pName);
		columnList.put("pdesc", pDesc);
		columnList.put("createtime", createTime);
		
		return columnList;
	}

	@Override
	protected void updateResultSet(ResultSet rs) throws SQLException {
		
		updateAllowNullColumns(rs, "aid", aid);
		
		updateNotAllowNullColumns(rs, "pname", pName);
		
		updateNotAllowNullColumns(rs, "pdesc", pDesc);
		
		updateNotAllowNullColumns(rs, "createtime", createTime);
		
	}
	
	
}
